// JavaScript Document
//这里的数据同样有缓存，值得注意啊，要不会莫名其妙花很多时间调试
//时间大的不能放在前面，莫名其妙的问题
window.getRandomColor = function(){
    return "hsb(" + Math.random()  + ", 1, 1)";
 }
window.st = 1000;
window.subtitle=
[
{"s":38000,"e":48000,"lyric":"骚货骚得够可以的了哈哈哈"}	
,{"s":100,"e":6000,"lyric":"sweety傲雪 i love you"}	
,{"s":st+=6000,"e": st+5600,"lyric":" 山田先生といえば、今度本を出版なさるそうだよ。 / 说到山田老师，听说最近要"}	 
,{"s":st+=6000,"e": st+5600,"lyric":"마음에 드는 사람이 있으면 결혼을 시키고자 합니다.如果有称心的人，打算让你结婚。"}
,{"s":st+=6000,"e": st+5600,"lyric":"（Папины дочки）	"}

 


,{"s":st+=6000,"e": st+5600,"lyric":"ขอหนังสือเดินทางท่านด้วย扩 囊色登汤 摊 度"}
,{"s":st+=6000,"e": st+5600,"lyric":"302.请您填写这张表。โปรดกรอกแบบฟอร์มนี้ด้วย"}	 
,{"s":st+=6000,"e": st+5600,"lyric":"春江潮水连海平，海上明月共潮生。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"滟滟随波千万里，何处春江无月明!"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江流宛转绕芳甸，月照花林皆似霰;"}	
,{"s":st+=6000,"e": st+5600,"lyric":"空里流霜不觉飞，汀上白沙看不见。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江天一色无纤尘，皎皎空中孤月轮。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江畔何人初见月？江月何年初照人？"}	
,{"s":st+=6000,"e": st+5600,"lyric":"人生代代无穷已，江月年年望相似。(望相似 一作只相似)"}	
,{"s":st+=6000,"e": st+5600,"lyric":"不知江月待何人，但见长江送流水。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"白云一片去悠悠，青枫浦上不胜愁。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"谁家今夜扁舟子？何处相思明月楼？"}	
,{"s":st+=6000,"e": st+5600,"lyric":"可怜楼上月徘徊，应照离人妆镜台。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"玉户帘中卷不去，捣衣砧上拂还来。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"此时相望不相闻，愿逐月华流照君。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"鸿雁长飞光不度，鱼龙潜跃水成文。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"昨夜闲潭梦落花，可怜春半不还家。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江水流春去欲尽，江潭落月复西斜。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"斜月沉沉藏海雾，碣石潇湘无限路"}	
,{"s":st+=6000,"e": st+5600,"lyric":"不知乘月几人归，落月摇情满江树。(落月 一作：落花)"}	
,{"s":st+=6000,"e": st+5600,"lyric":"程序编写：贺盛玉 20150123"}	
,{"s":st+=6000,"e": st+5600,"lyric":"嘻嘻"}	
,{"s":st+=6000,"e": st+5600,"lyric":"sweett"}	
,{"s":st+=6000,"e": st+5600,"lyric":"doll"}	
,{"s":st+=6000,"e": st+5600,"lyric":"export"}	

 	
,{"s":st+=6000,"e": st+5600,"lyric":"春江潮水连海平，海上明月共潮生。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"滟滟随波千万里，何处春江无月明!"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江流宛转绕芳甸，月照花林皆似霰;"}	
,{"s":st+=6000,"e": st+5600,"lyric":"空里流霜不觉飞，汀上白沙看不见。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江天一色无纤尘，皎皎空中孤月轮。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江畔何人初见月？江月何年初照人？"}	
,{"s":st+=6000,"e": st+5600,"lyric":"人生代代无穷已，江月年年望相似。(望相似 一作只相似)"}	
,{"s":st+=6000,"e": st+5600,"lyric":"不知江月待何人，但见长江送流水。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"白云一片去悠悠，青枫浦上不胜愁。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"谁家今夜扁舟子？何处相思明月楼？"}	
,{"s":st+=6000,"e": st+5600,"lyric":"可怜楼上月徘徊，应照离人妆镜台。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"玉户帘中卷不去，捣衣砧上拂还来。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"此时相望不相闻，愿逐月华流照君。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"鸿雁长飞光不度，鱼龙潜跃水成文。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"昨夜闲潭梦落花，可怜春半不还家。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"江水流春去欲尽，江潭落月复西斜。"}	
,{"s":st+=6000,"e": st+5600,"lyric":"斜月沉沉藏海雾，碣石潇湘无限路"}	
,{"s":st+=6000,"e": st+5600,"lyric":"不知乘月几人归，落月摇情满江树。(落月 一作：落花)"}	
,{"s":st+=6000,"e": st+5600,"lyric":"程序编写：贺盛玉 20150123"}	 	
]













 


 window._subtitle=Object.create(window.subtitle);
//window._subtitle= (window.subtitle).__$clone$__();

PlugLyric=function(oPlayer){
	//为哪个视频加载歌词,主要是通过它取得当前的播放时间
	this.oPlayer = oPlayer;	
	//当前的歌词，这个属性可以不要
	this.currentSubtitle ;
	//歌词项id 显示过的歌词push进 itemId数组中
	this.itemId = new Array();
	
	//是否显示歌词
	this.isShowSubtitle = true;
}

//判断歌词显示条件并trace出符合条件的那个歌词
PlugLyric.prototype.draw=function(oCtrace){
  //oCtrace.traceOne(subtitle[0].lyric); 
  var curr =  (this.oPlayer.player().currentTime).toFixed(2);
     
     for(var i=0,len=window.subtitle.length;i<len;i++){
	  var v = window.subtitle[i] 
	 
 
	  //以前的错误在于这里的表达式写错
	     if(  v.s * 0.001 <curr &&  curr <v.e *0.001    ){
		     if(! (this.itemId).__$inArray$__(v.s+'-'+v.e) 
				 && this.isShowSubtitle
			 ){
				
					 
				this.currentSubtitle = v.lyric ;	
				oCtrace.tTimeOut = Math.abs(v.e -v.s) ;
				
				//是否在指定时间后删除或隐藏歌词
				oCtrace.isKillTrace=true;		 
 
			    var color =  [].__$rselect$__(
			    new Array('red','green','blue','#f60','#f06','#60f','#06f','#09c','#3cc','#90f'
			    ,'#909','#060','#903','#f39','#000','#339c33 ','#30b030 ','#c90 ','#03c ','#969' 
			    ,'#de0022','#d0d','#009 ','#ffcc00','#3c3','#f90 ','#e99 ','#c60' )
			    );
				
			    if(""!==v.lyric){
			       oCtrace.trace (  v.lyric,color,60);
			    }
		 
			     this.itemId.push(v.s+'-'+v.e);
			 }
 
		 }  
 	
   } 
 	
}

//歌词隐藏显示切换
PlugLyric.prototype.toggle=function(){	
	this.isShowSubtitle =!this.isShowSubtitle
}

TOOLS.ready(function(){	

window.tre2 = new Ctrace();
tre2.isKillTrace =false;
window.treX = new Ctrace();
 // tre2.trace('ddd')
 //tre2.trace('ddd','#f06',40) 
 //清空弹出的字幕数组 
 

 
 window.setItemEmpty=function(ev){
	 if(arguments.callee.caller){
var ev = ev || window.event  ||  arguments.callee.caller.arguments[0]/*支持火狐*/ ;
	 }
   try{
	    window.oLyric.itemId = new Array();
	    var tracebox_Childs = document.getElementById(oLyTrace.boxid).childNodes;
	    for(var z=0; z<tracebox_Childs.length;z++){
			
		 try{
			 //(tracebox_Childs[z]).parentNode.removeChild(tracebox_Childs[z]);
			  (tracebox_Childs[z]).style.display = 'none';
			 
			 }catch(ee){console.warn(ee)}
		 
		}
		if(ev){
		TOOLS.Cevent.getAsc( ev );
		if(TOOLS.Cevent.eventCode===('S').charCodeAt(0)){
		 oLyric.toggle();   	
		}
		if(TOOLS.Cevent.eventCode===('1').charCodeAt(0)){
		 Ctrler.mode =1;   	
		}
		if(TOOLS.Cevent.eventCode===('2').charCodeAt(0)){
		 Ctrler.mode =2;  	
		}
		if(TOOLS.Cevent.eventCode===('3').charCodeAt(0)){
		 Ctrler.mode =3;  	
		}
		if( (new Array(49,50,51)).__$inArray$__( TOOLS.Cevent.eventCode ) ){
			  treX.traceOne('Ctrler.mode:'+Ctrler.mode+'(1随机播放,2顺序播放,3上一曲)',false)
			}
		}
		//window.getLyrJSON();
		//console.warn('window.getLyrJSON()');
	}catch(e){
		console.warn(e)
		}	 
	 
}
 window.addEventListener('keyup',setItemEmpty,false)
 window.addEventListener('mousedown',setItemEmpty,false) 
 
  window.mkPlugLyric = function(){
	 
		if(window.oPlayer && !window.oLyric){
			
		 window.oLyric = new PlugLyric(window.oPlayer);
		 //window.oLyric.isShowSubtitle = false;
		     
		}else{
		window.setTimeout(mkPlugLyric,1000)
		
		}
}  
 
 
window.getLyrJSON=function(){
 	
TOOLS.ajax(
window.convertLrcName() ,
  {
    method: 'POST',
  
    success: function(response,xhr){
		window.subtitle = Object.create( eval('('+response+')')  );
		console.log(window.subtitle);
	    //tre.traceOne(response,false )	 
		 
    },
    error: function(response){
		window.subtitle= Object.create(window._subtitle);
			
    }, 
	data:new FormData()
 
  }
);		
console.warn('window.getLyrJSON()');	
}
window.convertLrcName=function(){
	//这里千万不能有缓存，要不调试头大了，浪费了我很久 时间
	var s = 'http://127.0.0.1:91/VPLIST_MIN/1.lrc.txt?'+Math.random()+Math.random();
	
	try{
	s= oLyric.oPlayer.player().src;
	s=s.replace(/#/g,'%23');
	s=s.replace(/\.mp4$/g,'')+'.lrc.txt';
	console.log(s);
	}catch(e){
	console.log(e);	
	}
	return s;
}

window.setInterval(function(){
	
	window.convertLrcName()
	
	},1000)

 
})
